﻿@model RBAC.Web.Models.RoleUserModel
@using RBAC.Web.CustomHelpers
@using RBAC.Web.Mapper
@using RBAC.Web.Utilities
@{
    ViewBag.Title = "Add RoleUser";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
  
  		string returnUrl = Url.Action("ListRoleUser", "RoleUser");
	}

@section Styles {
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/form.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(function () {
            //How to setup Datepicker
            // SetDatePicker has 4 argurement
            // controlId -> id of control
            // maxdate -> maximun Date that can be selected 
            // mindate -> minimum Date that can be selected 
            // yearrange - > range of year
            // more information see http://api.jqueryui.com/datepicker/
            				//SetDatePicker("CreateDate", new Date(), '-71Y', 'c-70:c');
				SetDatePicker("CreateDate");
							//SetDatePicker("UpdateDate", new Date(), '-71Y', 'c-70:c');
				SetDatePicker("UpdateDate");
			            //ถ้าไม่มีกำหนด maxdate, mindate, yearrange
            SetDatePicker("FreeDate");			 

            //How to setup Lookup
            // SetLookupFor has 3 argurement
            // controlId -> id of control
            // getLookupId -> hidden control's id for getlookup link
            // popLookupId -> hidden control's id for poplookup link
            				SetExternalLookupFor("RoleUser_Role", "RoleUser_RoleGetExternalLookup", 
                "RoleUser_RolePopExternalLookup", 'RoleUser_Role|RoleUser_RoleLookupField|RoleRoleName');
							SetExternalLookupFor("RoleUser_User", "RoleUser_UserGetExternalLookup", 
                "RoleUser_UserPopExternalLookup", 'RoleUser_User|RoleUser_UserLookupField|UserEmail');
			        });
    </script>
}

<h2>New RoleUser</h2>
@using (Html.BeginForm("AddRoleUser", "RoleUser", FormMethod.Post, new { enctype = "multipart/form-data" })) {
    @Html.ValidationSummary(false)
    <fieldset>
        <legend>RoleUserModel</legend>
									<div class="two-column-container">		
					 
										  
			<div class="texteditor" style="display:none">
				@Html.LabelFor(model => model.Id)
				@Html.TextBoxFor(model => model.Id, new { @readonly = "readonly", @class = "txtFillNameExternal" })
									@Html.HiddenFor(model => model.Id)
					<input type="hidden" name="Mode" value="Edit" />
											<input type="hidden" name="OldValue" value="@(Model.Id == null ? "" : Model.Id +"")" />
												</div>

				@* START Calculation Field in use  *@
				 

			
						 
										             <div class="texteditor">
                @Html.LabelFor(model => model.CreateDate)
                @Html.DatePickerFor(model => model.CreateDate, "CreateDate", false)
                            </div>
			
								
					 
										             <div class="texteditor">
                @Html.LabelFor(model => model.UpdateDate)
                @Html.DatePickerFor(model => model.UpdateDate, "UpdateDate", false)
                            </div>
			
						 
									 

			 
			<div class="texteditor"  >
				@Html.LabelFor(model => model.UpdateBy)
				@Html.TextBoxFor(model => model.UpdateBy )
				  
		    </div>
			 

								
					 
									@* START ถ้าไม่มี lookup ไปหาแม่ ClildClass=False, LinkToParent=False *@
						<div class="texteditor">
                @Html.LabelFor(model => model.Role)
                @Html.ExternalLookup(model => model.RoleRoleCode, "RoleUser_Role").For(model => model.Role).Render()
				            </div>
				            <div class="texteditor">
                @Html.LabelFor(model => model.RoleRoleName)
                @Html.TextBoxFor(model => model.RoleRoleName, new { @readonly = "readonly", @class = "txtFillNameExternal" })
				            </div>
				            @* END ถ้าไม่มี lookup ไปหาแม่ ClildClass=False, LinkToParent=False *@

						 
									@* START ถ้าไม่มี lookup ไปหาแม่ ClildClass=False, LinkToParent=False *@
						<div class="texteditor">
                @Html.LabelFor(model => model.User)
                @Html.ExternalLookup(model => model.UserUsername, "RoleUser_User").For(model => model.User).Render()
				            </div>
				            <div class="texteditor">
                @Html.LabelFor(model => model.UserEmail)
                @Html.TextBoxFor(model => model.UserEmail, new { @readonly = "readonly", @class = "txtFillNameExternal" })
				            </div>
				            @* END ถ้าไม่มี lookup ไปหาแม่ ClildClass=False, LinkToParent=False *@

								
					 
													<div class="texteditor">
				@Html.LabelFor(model => model.ProjectId)
				@Html.TextBoxFor(model => model.ProjectId  )
							</div> @* END ไม่เป็น Attribute.Autokey *@
			 

			
							
		
				</div>     
        <div class="bottom-menu clear">
            <input type="submit" value="Add" />
            <input id="cancel" onclick="location.href='@returnUrl'" type="button" value="Cancel" />
        </div>
    </fieldset>
}
